package com.edu.contorller;


import com.edu.bean.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Controller
public class TestController2 {

    @RequestMapping("/test1")
    public String test1(String username, int age , Date birthday){
        System.out.println(username);
        System.out.println(age);
        System.out.println(birthday);
        return "index.jsp";
    }

    @RequestMapping("/test2")
    public String test2(@RequestParam("uname") String username, @RequestParam(value = "uage",required = false,defaultValue = "10")int age , @RequestParam("ubirth")Date birthday){
        System.out.println(username);
        System.out.println(age);
        System.out.println(birthday);
        return "index.jsp";
    }

    @RequestMapping("/test3")
    public String test3(User user){
        System.out.println(user);
        System.out.println(user.getMobile());
        return "index.jsp";
    }

    @RequestMapping("/test4")
    public String test4(String[] hobby){
        for (String s : hobby) {
            System.out.println(s);
        }
        return "index.jsp";
    }

    @RequestMapping("/test5")
    public String test5(User user,String pageNum){
        System.out.println(user);
        for(String s: user.getHobbies()){
            System.out.println(s);
        }
        System.out.println(pageNum);
        return "index.jsp";
    }

    @RequestMapping("/test6")
    public String test6(@RequestParam("hobby")List<String> hobby){
        for (String s : hobby) {
            System.out.println(s);
        }

        return "index.jsp";
    }

    @RequestMapping("/test7")
    public String test7(User user){
        System.out.println(user);
        for (String s : user.getHobbies()) {
            System.out.println(s);
        }
        return "index.jsp";
    }


    @RequestMapping("/test8")
    public String test8(User user){
        System.out.println(user);
        for (String s : user.getHobbies()) {
            System.out.println(s);
        }
        System.out.println(user.getRelations());
        return "index.jsp";
    }
}
